﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using AFCEPF.BankApplication.BLL;
using AFCEPF.BankApplication.DAL;
using AFCEPF.BankApplication.Tests.Utilities;

using NUnit.Framework;

namespace AFCEPF.BankApplication.Tests
{
    [TestFixture]
    class Test_MappedProperty
    {
        [Test]
        public void Test_Property_PropertyName()
        {
            MockPerson p = new MockPerson();
            MappedProperty m = p.MappedProperties["Name"];
            Assert.IsTrue(m.PropertyName == "Name");
        }

        [Test]
        public void Test_Property_PropertyFieldName()
        {
            MockPerson p = new MockPerson();
            MappedProperty m = p.MappedProperties["Name"];
            Assert.IsTrue(m.PropertyFieldName == "Nom");
        }

        [Test]
        public void Test_Property_PropertyValue_Getter()
        {
            MockPerson p = new MockPerson();
            p.Name = "aa";
            MappedProperty m = p.MappedProperties["Name"];
            Assert.IsTrue((string)m.PropertyValue == "aa");
        }

        [Test]
        public void Test_Property_PropertyValue_Setter()
        {
            MockPerson p = new MockPerson();
            
            MappedProperty m = p.MappedProperties["Name"];
            m.PropertyValue = "aa";
            
            Assert.IsTrue(p.Name == "aa");
        }

        [Test]
        public void Test_Property_IsPrimaryKey()
        {
            MockPerson p = new MockPerson();            
            MappedProperty m = p.MappedProperties["Id"];
            Assert.IsTrue(m.IsPrimaryKey);
        }

        [Test]
        public void Test_Property_MappedObject()
        {
            MockPerson p = new MockPerson();
            MappedProperty m = p.MappedProperties["Id"];
            Assert.AreSame(p, m.MappedObject);
        }

    }
}
